# load data
datos <- read.table("traceroute_promedio_wwwsapocomza.txt", header=T) # hopNmbr host ms ms2
graf <- "traceroute_promedio_wwwsapocomza.png"

hosts = datos$host
mss = datos$ms
mss2 = datos$ms2

len = length(hosts)

print(datos)

# plot
png(filename=graf, width=1024, height=768, bg="white")

# increase y-axis margin. (bottom, left, top, right)
par(mar=c(10,5,5,2))

# Calculate range from 0 to max value
g_range <- range(0, mss)

# Graph using y axis that ranges from 0 to max 
# Turn off axes and 
# annotations (axis labels) so we can specify them ourself
plot(rep(1000, len), type="l", col="grey80", ylim=g_range, axes=FALSE, ann=FALSE)


# Make y axis with horizontal labels that display ticks at 
# every 100 marks. 100*0:g_range[2] is equivalent to c(0,100,200,...,1000).
axis(2, las=1, 100*0:g_range[2])

# Make x axis tick marks without labels
axis(1, lab=F, at=1:len)

# Plot x axis labels at default tick marks with labels at 
# 45 degree angle
text(1:len, par("usr")[3] - 50, srt=45, adj=1, labels=hosts, xpd=T, cex=0.8)


# Create box around plot
box()

# Graph
lines(mss, type="b", pch=23, lty=2, col="red")
lines(mss2, type="b", pch=22, lty=4, col="blue")
title(main="Promedio de mediciones ruta hacia www.sapo.com.za (Enlace EEUU - UK)")
title(ylab="Time (ms)")
   
dev.off()
